#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""  
@Project : pythonProject
@File : regist.py
@Author : 万能小魏
@Time : 2024/8/16 14:32  
@脚本说明 : 

"""
import uuid
from datetime import datetime

import woniu.dataList as dataList


def register():
    # 接收并检查用户输入的账号和密码和确认密码
    username = input("请输出您的注册账号:\n")
    tempList = list(filter(lambda u: u['username'] == username, dataList.userList))
    if len(tempList) != 0:
        print("该账号已存在!")
    else:
        passwd = input("请输出您的密码:\n")
        passwdtoo = input("请再次输出您的密码:\n")
        if passwd == passwdtoo:
            id:str(uuid.uuid1()).split("-")[0]  # uuid生成不重复ID
            email = input("请输出您的邮箱:\n")
            gender = input("请输出您的性别(男/女):\n")
            register = datetime.now().strftime("%Y-%m-%d")
            age = input("请输出您的年龄:\n")
            dataList.userList.append({
                "id": str(len(dataList.userList) + 1).zfill(8),  # 补0
                "username": username,
                "password": passwd,
                "email": email,
                "gender": gender,
                "register": register,
                "age": age,
                "status": True
            })
            print("恭喜", username, "注册成功!")
        else:
            print("两次输入的密码不一致!")